# Maintainer: Martell Malone <martellmalone@gmail.com>

pkgname="crosstool-ng"
pkgver=1.21.0
pkgrel=1
pkgdesc="A cross-platform open-source toolchain system"
arch=('i686' 'x86_64')
url="http://www.crosstool-ng.org/"
license=("MIT")
makedepends=("autoconf" "automake-wrapper" "binutils" "bison"
             "flex" "gettext-devel" "git" "gcc" "gperf"
             "patch" "libtool" "make" "ncurses-devel"
             "tar" "texinfo" "wget" "xz")
depends=("ncurses" "libintl")
options=('staticlibs' 'strip')
source=("http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-${pkgver}.tar.xz"{,.sig}
        "0001-Modify-config-to-support-correct-Mingw64-Triplet-Nam.patch"
        "0002-use-wide-versions-of-libs-for-nconf.patch"
        "0003-modify-kconfig-make-lintl.patch"
        "0004-kconfig-nconf-fix-compile-with-ncurses-reentrant-API.patch")
md5sums=('ee969dff8783605cd4acf4840113a119'
         'SKIP'
         'a893266875be8b7286e407a0df53152a'
         '4a2dd7faa9198e66f83907cb6ef53412'
         'fd46a1565c20ecb3ba297903247196d9'
         '9af4f3da31f42b731f8daf1431a0a0fb')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-Modify-config-to-support-correct-Mingw64-Triplet-Nam.patch"
  patch -p1 -i "${srcdir}/0002-use-wide-versions-of-libs-for-nconf.patch"
  patch -p1 -i "${srcdir}/0003-modify-kconfig-make-lintl.patch"
  patch -p1 -i "${srcdir}/0004-kconfig-nconf-fix-compile-with-ncurses-reentrant-API.patch"
  ./bootstrap
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
    --build=${CHOST} \
    --prefix=/usr

  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR=${pkgdir} install
}
